{% extends "toast/base.template.html" %}
{% load toast_filters %}

{% block breadcrumbs %}
	<li class="active">{{ meeting.name }}</li>
{% endblock %}


{% block sidecontent %}
	<div class="btn-toolbar">
		<div class="btn-group">
			<a class="btn active" href="/toast/meeting/view/{{ meeting.id }}">View</a>
			<a class="btn" href="/toast/meeting/edit/{{ meeting.id }}">Edit</a>
			<a class="btn confirm" href="/toast/meeting/delete/{{ meeting.id }}" message="Are you sure you want to delete {{ meeting.name }}?">Delete</a>
		</div>
	</div>

	<p class="lead">Add Member</p>
	<form method="POST" action="/toast/attendance/add/">
	{% csrf_token %}
		<h6>{{ form.member.label }}</h6>
		{{ form.member}}
		<p class="text-error">{{ form.member.errors.as_text }}</p>

		<h6>{{ form.role.label }}</h6>
		{{ form.role }}
		<p class="text-error">{{ form.role.errors.as_text }}</p>

		<input type="hidden" name="meeting" value="{{ meeting.id }}" />
		<input class="btn btn-primary" name="meeting_add" type="submit" value="Add Member" />
	</form>

		<h5>{{ meeting.name }}</h5>
	<address>
		<b>{{ meeting.address.name }}</b><br />
		{{ meeting.address.street_address }}<br />
		{{ meeting.address.city }}
		{{ meeting.address.state.short_name }}, {{ meeting.address.postalcode }}
	</address>
	<p>Start: {{ meeting.start_datetime }}</p>
	<p>End: {{ meeting.end_datetime }}</p>
{% endblock %}


{% block content %}
{% if list_of_attendance %}
	<table class="table">
		<thead>
		<tr>
			<th>Member</th>
			<th>Assigned Role</th>
			<th>Action(s)</th>
		</tr>
		</thead>

		<tbody>
		{% for key, attendance in list_of_attendance.items %}
		<tr>
			<td><a href="/toast/attendance/view/{{ attendance.0.id }}">{{ attendance.0.member.first_name_first|ucwords }}</a></td>
			{% if attendance|length == 1 %}
			<td>{{ attendance.0.role.name|ucwords }}</td>
			{% else %}
			<td>
			<ul>
			{% for attend in attendance %}
				<li>{{ attend.role.name|ucwords }}</li>
			{% endfor %}
			</ul>
			</td>
			{% endif %}
			<td>
			<div class="btn-group pull-right">
				<a class="btn btn-primary" href="#"><i class="icon-wrench icon-white"></i> Actions</a>
				<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="/toast/attendance/view/{{ attendance.id }}"><i class="icon-eye-open"></i> View</a></li>
					<li><a href="/toast/attendance/edit/{{ attendance.id }}"><i class="icon-pencil"></i> Edit</a></li>
					<li><a href="/toast/attendance/delete/{{ attendance.id }}" class="confirm" message="Are you sure you want to delete {{ attendance.member.first_name }} {{ attendance.member.last_name }} as {{ attendance.role }}?"><i class="icon-trash"></i> Delete</a></li>
				</ul>
			</div>
			<div class="clearfix"></div>
			</td>
		</tr>
		{% endfor %}
		</tbody>
	</table>
{% else %}
	<p class="text-info">No members added to this meeting.</p>
{% endif %}
{% endblock %}




